<?php
ob_start();
/*
	控件每次向此文件POST数据
	逻辑：
		1.更新数据库进度
		2.将文件块数据保存到服务器中。
	更新记录：
		2017-05-31 创建
		2017-06-01 增加目录信息 
*/
require '../../vendor/autoload.php';

use database\DBFile;
use database\DBFolder;
use model\FileInf;
use biz\up7_biz_event;
use biz\fd_scan;
use biz\FolderSchemaDB;

$id   	= $_GET["id"];
$uid  	= $_GET["uid"];
$cbk  	= $_GET["callback"];//jsonp
$ret  	= 0;

//参数为空
if ( strlen($id) > 0 )
{	
	$folder = new FileInf();
	$folder->id = $id;
	DBFile::read($folder);
	$folder->uid = $uid;
	
	//根节点
	$root = new FileInf();
	$root->id = $folder->pidRoot;
	$root->uid = $folder->uid;
	
	//当前节点是根节点
	if( empty(trim($root->id))) $root->id = $folder->id;
	
	//保存层级结构信息->解析层级信息文件
	$fsd = new FolderSchemaDB();
	$fsd->save($folder);
	
	$db = new DBFile();
	$db->fd_scan($id, $uid);
	
	$fd = new DBFolder();
	$fd->Complete($id, $uid);
	
	$ret = 1;
	
	//触发事件
	up7_biz_event::folder_post_complete($id);
}
echo "$cbk( $ret )";
header('Content-Length: ' . ob_get_length());
?>